package com.zzw.hj55;

import java.util.Scanner;

/**
 * @Project: hw_java
 * @Description: 挑7
 * @Author: zzw
 */
// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
    public static boolean containSeven(int num) {
        while (num > 0) {
            int rem = num % 10;
            if (rem == 7) {
                return true;
            }
            num = num / 10;
        }
        return false;
    }

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int count = 0;
        for (int i = 1; i <= n; i++) {
            if (containSeven(i) || (i % 7 == 0)) {
                count++;
            }
        }
        System.out.println(count);
    }
}